package com.inspsys.video.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.inspsys.common.annotation.Log;
import com.inspsys.common.core.controller.BaseController;
import com.inspsys.common.core.domain.AjaxResult;
import com.inspsys.common.enums.BusinessType;
import com.inspsys.common.utils.poi.ExcelUtil;
import com.inspsys.video.domain.VideoDevice;
import com.inspsys.video.service.IVideoDeviceService;
import com.inspsys.common.core.page.TableDataInfo;

/**
 * 视频设备管理Controller
 * 
 * @author inspsys
 * @date 2025-02-12
 */
@RestController
@RequestMapping("/video/device")
public class VideoDeviceController extends BaseController {
    @Autowired
    private IVideoDeviceService videoDeviceService;

    /**
     * 查询视频设备管理列表
     */
    // @PreAuthorize("@ss.hasPermi('system:device:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoDevice videoDevice) {
        startPage();
        List<VideoDevice> list = videoDeviceService.selectVideoDeviceList(videoDevice);
        return getDataTable(list);
    }

    /**
     * 导出视频设备管理列表
     */
    // @PreAuthorize("@ss.hasPermi('system:device:export')")
    @Log(title = "视频设备管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoDevice videoDevice) {
        List<VideoDevice> list = videoDeviceService.selectVideoDeviceList(videoDevice);
        ExcelUtil<VideoDevice> util = new ExcelUtil<VideoDevice>(VideoDevice.class);
        util.exportExcel(response, list, "视频设备管理数据");
    }

    /**
     * 获取视频设备管理详细信息
     */
    // @PreAuthorize("@ss.hasPermi('system:device:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(videoDeviceService.selectVideoDeviceById(id));
    }

    /**
     * 新增视频设备管理
     */
    // @PreAuthorize("@ss.hasPermi('system:device:add')")
    @Log(title = "视频设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoDevice videoDevice) {
        return toAjax(videoDeviceService.insertVideoDevice(videoDevice));
    }

    /**
     * 修改视频设备管理
     */
    // @PreAuthorize("@ss.hasPermi('system:device:edit')")
    @Log(title = "视频设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoDevice videoDevice) {
        return toAjax(videoDeviceService.updateVideoDevice(videoDevice));
    }

    /**
     * 删除视频设备管理
     */
    // @PreAuthorize("@ss.hasPermi('system:device:remove')")
    @Log(title = "视频设备管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(videoDeviceService.deleteVideoDeviceByIds(ids));
    }
}
